import 'package:equatable/equatable.dart';
import 'package:backend.purchases/domain/entities/app_store_api/app_store_api_environment.dart';

class AppStoreApiEnvironmentDto extends Equatable {
  const AppStoreApiEnvironmentDto._internal({
    required this.environmentString,
  });

  final String environmentString;

  @override
  List<Object?> get props {
    return [
      environmentString,
    ];
  }

  factory AppStoreApiEnvironmentDto.fromString(String environmentString) {
    return AppStoreApiEnvironmentDto._internal(
      environmentString: environmentString,
    );
  }

  AppStoreApiEnvironment toEntity() {
    if (environmentString == 'Sandbox') {
      return AppStoreApiEnvironment.sandbox;
    }

    if (environmentString == 'Production') {
      return AppStoreApiEnvironment.production;
    }

    throw UnimplementedError();
  }
}
